<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="处理申请" back-icon-color='#333333' height="50" :border-bottom="false">
		</u-navbar>
		<view class="list">
			<view class="designation">
				<text>名称:</text>
				<text>{{conference_name}}</text>
			</view>
			<view class="num">
				<text>
					ID:
				</text>
				<text>{{conference_id}}</text>
			</view>
			<view class="" style="width:710rox; margin-left:20rpx; border-bottom:1rpx solid #F2F2F2; height:20rpx;">

			</view>
			<view class="address">
				<text>地点</text>
				<text>{{conference_address}}</text>
			</view>
			<view class="type">
				<text>类型</text>
				<text>{{conference_type}}</text>
			</view>
			<view class="capacity">
				<text>容纳人数</text>
				<text>{{conference_people}}</text>
			</view>

			<view class="remark">
				<text>备注</text>
				<text>{{conference_note}}</text>
			</view>
			<view class="use_time">
				<text>使用时间</text>
				<text>{{start_date}}-</text>
				<text>{{end_date}}</text>
			</view>
			<view class="" style="width:710rox; margin-left:20rpx; border-bottom:1rpx solid #F2F2F2; height:20rpx;">

			</view>
			<view class="event">
				<text>事件</text>
				<input type="text" value="" v-model="conference_event" placeholder="单行输入" />
			</view>
			<view class="handing">
				<text class="results">受理结果</text>
				<view class="toggle">
					<text :style="{color:left_color,background:left_background_color}"
						@click="changeLeftColor">通过</text>
					<text :style="{color:right_color,background:right_background_color}"
						@click="changeRightColor">驳回</text>
				</view>
			</view>
			<view class="remarks">
				<text>审核备注</text>
			</view>
			<view class=""
				style="width:710rpx; height:15rpx; margin-left:20rpx; background:#F2F2F2; border-top-left-radius:12rpx; border-top-right-radius:12rpx;">

			</view>
			<textarea value="" v-model="input_content" placeholder="单行输入"
				style="width:710rpx; height:160rpx; margin-left:20rpx; background:#F2F2F2; text-indent:1em; border-bottom-left-radius:12rpx; border-bottom-right-radius:12rpx;" />
			<view class="" style="width:100%; height:25rpx;">
			</view>
		</view>
		<view class="confirm">
			<view class="verify" @click="applyHandle">
				{{verify}}
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../request.js'
	export default {
		data() {
			return {
				left_color: '#fff',
				conference_name: '',
				conference_id: '',
				conference_address: '',
				conference_type: '',
				conference_people: '',
				start_date: '',
				end_date: '',
				conference_note: '',
				conference_event: '',
				left_background_color: '#2E98FA',
				right_color: '#333333',
				right_background_color: '#F2F2F2',
				event_input: '',
				input_content: '',
				verify: '确认',
				form: {
					apply_id: '',
					handle: 1
				},
				meeting_list: "",
				meeting_id: "",
			}
		},
		onLoad(option) {
			if (option) {
				// let {
				// 	name,
				// 	apply_id,
				// 	address,
				// 	type,
				// 	note,
				// 	start_date,
				// 	end_date,
				// 	event,
				// 	people
				// } = option;
				// this.conference_name = name;
				// this.conference_address = address;
				// this.conference_id = apply_id;
				// this.conference_type = type;
				// this.conference_people = people;
				// this.conference_note = note;
				// this.conference_event = event;
				// this.start_date = start_date;
				// this.end_date = end_date;
				// this.form.apply_id = apply_id;
				if (option.id) {
					this.meeting_id = option.id;
				}
				this.applyDetail();
			}


		},
		methods: {
			changeLeftColor() {
				if (this.left_background_color == '#2E98FA') {
					this.left_color = '#333333';
					this.left_background_color = '#F2F2F2';
					this.right_color = '#fff';
					this.right_background_color = '#2E98FA';
				} else {
					this.left_color = '#fff';
					this.left_background_color = '#2E98FA';
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
					this.form.handle = 1;
				}
			},
			changeRightColor() {
				if (this.right_background_color == '#2E98FA') {
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
					this.left_color = '#fff';
					this.left_background_color = '#2E98FA';
				} else {
					this.right_color = '#fff';
					this.right_background_color = '#2E98FA';
					this.left_color = '#333333';
					this.left_background_color = '#F2F2F2';
					this.form.handle = 2;
				}
			},
			applyDetail() {
				let _this = this;
				let base_url = uni.getStorageSync('host');
				request({
					url: base_url + 'teacher/meeting_room/applyDetail',
					method: 'post',
					data: {
						apply_id: this.meeting_id ? this.meeting_id : 14,
					},
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data.data);
							_this.meeting_list = res.data.data;
							_this.form.apply_id = _this.meeting_list.apply_id;
							_this.conference_name = _this.meeting_list.meeting_room_detail.name;
							_this.conference_address =_this.meeting_list.meeting_room_detail.place;
							_this.conference_id =_this.meeting_list.apply_id;
							_this.conference_type =_this.meeting_list.meeting_room_detail.type;
							_this.conference_people =_this.meeting_list.meeting_room_detail.people;
							_this.conference_note =_this.meeting_list.meeting_room_detail.remark;
							_this.conference_event =_this.meeting_list.event;
							_this.start_date =_this.meeting_list.start_time;
							_this.end_date =_this.meeting_list.end_time;
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
			applyHandle() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/meeting_room/applyHandle',
					method: 'post',
					data: {
						...this.form
					},
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data);
							_this.$toLink('../function_room/function_room', {
								function_id: 2
							})
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		overflow: hidden;
		background: #F2F2F2;

		.list {
			width: 100%;
			margin-top: 20rpx;
			background: #fff;

			.designation {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 28rpx;

					&:nth-child(1) {
						color: #333333;
						margin-left: 5rpx;
						width: 120rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.num {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 28rpx;

					&:nth-child(1) {
						color: #333333;
						margin-left: 30rpx;
						width: 90rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.address {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.event {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}
				}

				input {
					&:nth-child(2) {
						outline: none;
						border: none;
						margin-top: 25rpx;
						font-size: 26rpx;
						color: #666666;
						width: 400rpx;
					}
				}
			}

			.type {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.use_time {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
						width: 275rpx;

					}

					&:nth-child(3) {
						color: #333333;
					}
				}
			}

			.capacity {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.remark {
				width: 710rpx;
				margin-left: 20rpx;
				height: 120rpx;
				display: flex;
				justify-content: flex-start;


				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.handing {
				width: 710rpx;
				margin-left: 20rpx;
				height: 100rpx;
				align-items: center;
				display: flex;
				justify-content: flex-start;

				.results {
					width: 150rpx;
					color: #666666;
					font-size: 26rpx;
				}

				.toggle {
					width: 160rpx;
					height: 40rpx;
					position: relative;

					text {
						&:nth-child(1) {
							border-top-left-radius: 20rpx;
							border-bottom-left-radius: 20rpx;
							background: #2E98FA;
							color: #fff;
							text-align: center;
							line-height: 40rpx;
							height: 40rpx;
							font-size: 20rpx;
							width: 80rpx;
							position: absolute;
							top: 0;
							left: 0;
						}

						&:nth-child(2) {
							border-top-right-radius: 20rpx;
							border-bottom-right-radius: 20rpx;
							background: #F2F2F2;
							color: #333333;
							text-align: center;
							line-height: 40rpx;
							height: 40rpx;
							font-size: 20rpx;
							width: 80rpx;
							position: absolute;
							top: 0;
							left: 80rpx;
						}
					}
				}
			}

			.remarks {
				width: 710rpx;
				margin-left: 20rpx;
				height: 50rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					color: #666666;
					width: 150rpx;
				}
			}
		}

		.confirm {
			width: 100%;
			height: 300rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			.verify {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: linear-gradient(to right, #2C78FE, #32B0FF);
				color: #fff;
				font-size: 30rpx;
			}
		}
	}
</style>
